TRIGGER_TOUCH = 1 << 1
TRIGGER_VISIBLE = 1 << 2
TRIGGER_DISABLE = 1 << 3

class Trigger(object):
    """A trigger is an object that is activated upon a certain event."""
    enable=True
    trigger_type=TRIGGER_DISABLE

    def activate(self, what):
        """Activate the trigger as `what`"""
        raise NotImplemented()

    def think(self):
        """Every frame this should be called."""
        raise NotImplemented()

    def on_touch(self, what):
        """Logic when `what` touches the trigger."""
        raise NotImplemented()

    def on_visible(self, what):
        """Logic when `what` sees the trigger."""
        raise NotImplemented()

    def post_activate(self):
        raise NotImplemented()


class TriggerOnce(Trigger):
    def __init__(self, callback, trigger_type=TRIGGER_TOUCH):
        self.callback = callback
        self.trigger_type = trigger_type

    def activate(self, what):
        if self.enable:
            if self.callback(what):
                self.post_activate()

    def post_activate(self):
        self.enable = False
